import request from '@/utils/request'
import qs from 'qs'

export function findListByPage(param) {
  return request({
    url: 'api/scriptPublish/version/page',
    method: 'get',
    param
  })
}

export function findById(id) {
  return request({
    url: 'api/scriptPublish/version' + '/' + id,
    method: 'get',
    id
  })
}

export function add(data) {
  return request({
    url: 'api/scriptPublish/version',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/scriptPublish/version/' + ids,
    method: 'delete'
  })
}

export function edit(data) {
  return request({
    url: 'api/scriptPublish/version',
    method: 'put',
    data
  })
}

export function publish(data, serverIds, clusterIds, publishUser) {
  return request({
    url: 'api/scriptPublish/version/publish/' + serverIds + '/' + clusterIds + '/' + publishUser,
    method: 'post',
    data,
    clusterIds,
    publishUser
  })
}

export function getUserList(serverId,ids) {
  return request({
    url: 'api/scriptPublish/version/userList/' + serverId+'/'+ids,
    method: 'get',
    serverId,
    ids
  })
}

export default {
  findListByPage,
  findById,
  add,
  del,
  edit,
  publish,
  getUserList
}
